﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using OneSoft.EntityCore;
using OneSoft.DataAccess;
using BySoft.Server.Common.Entity;
using BySoft.Server.Common.Schema;
using BySoft.Server.DataAccess;
using BySoft.Server.Common.Enum;
using BySoft.Server.Common;


namespace BySoft.Server.Business 
{
    public partial class StStockmanagedetail
    {
        public static DataTable SelectStockAll(string strKey)
        {
            return StStockmanagedetailDA.SelectStockAll(strKey);
        }

        public static void ListCheck(List<BsMatinstockdetailEntity> lty, List<StStockmanagedetailEntity> ltyStockDetail)
        {
            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                broker.BeginTransaction();
                try
                { 
                    for (int i = 0; i < lty.Count; i++)
                    {
                        DataAccessCommon.UpdateOnly(lty[i], broker);
                    }
                    for (int i = 0; i < ltyStockDetail.Count; i++)
                    {
                        DataAccessCommon.Insert(ltyStockDetail[i], true, broker);
                    }
                    broker.Commit();
                }
                catch
                {
                    broker.Rollback();
                    throw;
                }
            }
        }

        public static void ListCheckCance(BsMatinstockdetailEntity entity, StStockmanagedetailEntity enStockDetail)
        {
            using (DataAccessBroker broker = DataAccessFactory.Instance())
            {
                broker.BeginTransaction();
                try
                {
                    DataAccessCommon.UpdateOnly(entity, broker);
                    StStockmanagedetailDA.ListCheckCance(enStockDetail, broker);
                    broker.Commit();
                }
                catch
                {
                    broker.Rollback();
                    throw;
                }
            }
        }

    }
}
